//
//  ViewController.m
//  SearchDisplayDemo
//
//  Created by Cluy on 14/11/7.
//  Copyright (c) 2014年 sunflows. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    searchbar.delegate = self;
    searchbar.showsCancelButton =NO;
}

- (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar{
    searchbar.showsCancelButton =YES;
    secondView.hidden =YES;
    [self.navigationController setNavigationBarHidden:YES animated:YES];
}
- (BOOL)searchBarShouldEndEditing:(UISearchBar *)searchBar{
    
    return YES;
}
- (void)searchBarTextDidEndEditing:(UISearchBar *)searchBar{
    [searchbar resignFirstResponder];
}
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText{
     searchBar.showsCancelButton =YES;
}
- (BOOL)searchBar:(UISearchBar *)searchBar shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text NS_AVAILABLE_IOS(3_0){
    return YES;
}
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar{
    
}
- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar{
     searchbar.showsCancelButton =NO;
    secondView.hidden = NO;
     [self.navigationController setNavigationBarHidden:NO animated:YES];
     [searchbar resignFirstResponder];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
